package com.springapp.jsonmodel;

import com.springapp.model.Desk;
import com.springapp.model.Shape;
import com.springapp.model.Status;

/**
 * Created with IntelliJ IDEA. User: exceptis
 */
public class TableJson {

    private Integer id;

    private Integer x;

    private Integer y;

    private Integer orderId;

    private Status status;

    private Shape shape;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getX() {
        return x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return y;
    }

    public void setY(Integer y) {
        this.y = y;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Status getStatus() {
        return status;
    }

    public void setStatus(Status status) {
        this.status = status;
    }

    public Shape getShape() {
        return shape;
    }

    public void setShape(Shape shape) {
        this.shape = shape;
    }

    public static TableJson toModel(Desk desk) {
        TableJson jsonModel = new TableJson();
        jsonModel.setId(desk.getId());
        jsonModel.setX(desk.getPositionX());
        jsonModel.setY(desk.getPositionY());
        if (desk.getOrder() != null) {
            jsonModel.setOrderId(desk.getOrder().getId());
        }
        jsonModel.setStatus(desk.getStatus());
        jsonModel.setShape(desk.getShape());
        return jsonModel;
    }
}
